<?php
namespace app\common\model\admin;

use think\Model;

class AuthRule extends Model
{
    protected $updateTime = false;

    public function ruletree($rulesRes){
        return $this->sort($rulesRes);
    }

    public function sort($ruleRes,$parent_id=0,$level=0){
        static $arr = [];
        foreach ($ruleRes as $k=>$v){
            if ($v['parent_id'] == $parent_id){
                $v['level'] = $level;
                $arr[] = $v;
                $this->sort($ruleRes,$v['id'],$level+1);
            }
        }
        return $arr;

    }
}